home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Auge 4000 / Auge 4000 #78 (1994-04-30)(Amiga User Gruppe Einzugsgebiet 4000).zip / Auge 4000 #78 (1994-04-30)(Amiga User Gruppe Einzugsgebiet 4000).adf / Watchdog / watchdog.c < prev    next >
C/C++ Source or Header  |  1994-03-24  |  2KB  |  77 lines

  1. /* Watchdog - Überwacht einzelne dateien und gibt bei Veränderung einen
  2.    Alert aus. Speziell für Christian "CTAF" Lemiesz...                  */
  3.  
  4. #include <dos/notify.h>
  5. #include <exec/libraries.h>
  6. #include <exec/memory.h>
  7. #include <intuition/intuition.h>
  8. #include <libraries/dos.h>
  9. #include <libraries/dosextens.h>
  10. #include <workbench/startup.h>
  11. #include <workbench/workbench.h>
  12.  
  13.  
  14. extern struct DosLibrary *DOSBase;
  15. struct Library *CxBase;
  16. struct MsgPort *myport=NULL;
  17. struct NotifyMessage *msg;
  18.  
  19. UBYTE *aMsg=
  20.     "\x00\xE0\x10" "*** Dumm-User-Alarm  #1 ***" "\x00\x01"
  21.     "\x00\xE0\x1A" "Finger weg von dieser Datei" "\x00\x01"
  22.     "\x00\xD8\x2A" "PRESS MOUSEBUTTON TO CONTINUE" "\x00";
  23.  
  24. WatchdogRequest(TEXT *name)
  25. {
  26.     DisplayAlert(DEADEND_ALERT, aMsg, 55);
  27. }
  28.  
  29. main(int argc, char *argv[])
  30. {
  31.     long Version;
  32.     char name[256];
  33.     char *watch;
  34.     UBYTE **ttypes;
  35.     BOOL quit=FALSE;
  36.     struct NotifyRequest *nreq;
  37.     
  38.     if((Version=DOSBase->dl_lib.lib_Version) > 36)
  39.     {
  40.         if(CxBase=(struct Library *) OpenLibrary("commodities.library",37))
  41.         {
  42.             myport=(struct MsgPort *) CreatePort(0,0);
  43.  
  44.             ttypes =(UBYTE **) ArgArrayInit(argc, &argv[0]);
  45.         
  46.             watch=(UBYTE *)ArgString(ttypes, "WATCH", ":disk.info");
  47.  
  48.             if(nreq=(struct NotifyRequest *)AllocVec(sizeof(struct NotifyRequest), MEMF_CLEAR|MEMF_PUBLIC))
  49.             {
  50.                 nreq->nr_Name=watch;
  51.                 nreq->nr_Flags=NRF_SEND_MESSAGE;
  52.                 nreq->nr_stuff.nr_Msg.nr_Port=myport;
  53.                 
  54.                 if(StartNotify(nreq))
  55.                 {
  56.                     WaitPort(myport);
  57.                     msg=(struct NotifyMessage *)GetMsg(myport);
  58.                     strncpy(name, msg->nm_NReq->nr_Name, 255);
  59.                     ReplyMsg(msg);
  60.                     WatchdogRequest(name);
  61.                 }
  62.                 EndNotify(nreq);
  63.                 FreeVec(nreq);
  64.             }
  65.             DeletePort(myport);
  66.             ArgArrayDone(); 
  67.         }
  68.         CloseLibrary(CxBase);
  69.     }
  70. }
  71.             
  72. void wbmain(wbs)
  73. struct WBStartup *wbs;
  74. {
  75.     main(0 , (LONG *) wbs);
  76. }
  77.